<?php
// +----------------------------------------------------------------------
// | genadmin [ genadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\admin\model\finance;

use app\admin\model\user\UserMember;
use app\basic\BaseNormalModel;

/**
 * 积分记录模型
 */
class UserScoreLog extends BaseNormalModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 数据库表名称
     * @var string
     */
    protected $table = 'eb_user_score_log';


    public function searchNickNameAttr($query, $value, $data)
    {
        $user_id = UserMember::where('nickname','like', $value . '%')->value("id");
        $query->where('user_id','=',$user_id);

    }

    /**
     * 关联模型user
     */
    public function user()
    {
        return $this->hasOne(UserMember::class, 'id', 'user_id');
    }

}
